//
// Created by 26090 on 24-12-17.
//

#ifndef MASTERMACHINE_H
#define MASTERMACHINE_H

#include "main.h"

#define LAST 0
#define CURRENT 1
#define FUTURE 2

typedef enum
{
     DIRECTION_UNKNOWN = 0,
     DIRECTION_CW,
     DIRECTION_CCW
} Direction_e;

#define DIRECTION DIRECTION_CW



typedef enum
{
     COLOR_NONE,
     COLOR_RED,
     COLOR_GREEN,
     COLOR_BLUE,
}Color_e;

typedef enum
{
     STATE_IDLE,
     STATE_PICK_RAW,
     STATE_ROUGH_AREA,
     STATE_FASHIONING_AREA,
     STATE_FINISHED
}State_e;

typedef struct
{
     float xdis,ydis;
     float remain_time;       //转盘剩余时间

     Color_e color[3][3];        //以向车体定义，右上角为0，左上角为1，下方为2
     uint8_t is_stop;         //转盘是否停转
     uint8_t last_is_stop;
     Direction_e direction;

     uint8_t move_to;
}Master_recv_s;

typedef struct
{
     State_e state;
}Master_send_s;

Master_recv_s *CommunicateInit(UART_HandleTypeDef *_handle);

void CommunicateSend(Master_send_s *send);

void CalMasterTimer();

void EmptyMasterTimer();

#endif //MASTERMACHINE_H
